home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- USERKEY.C
- Author: Mario Westphal
- Copyright ⌐ 1997,98 Mario M. Westphal
- Date: Tuesday, July 01, 1997
- Revised Sunday, April 06, 1998
-
-
- This DLL serves as a sample for a user-defined Key DLL..
-
- *****************************************************************************/
-
- // Include the required definitions from the Sort Solution interface
- #include "..\..\Include\sortsoli.h"
-
-
- /////////////////////////////////////////////////////////////////////////////
- // This function gets called when Sort Solution needs to compare two keys
- // pKey1 points to the first key and KeyLen1 is the length in byte of the
- // memory area pointed to by pKey1.
- // pKey2 points to the second key and KeyLen2 is the length in byte of the
- // memory area pointed to by pKey2.
- // pData points to a string, containing whatever the user has used as the
- // "Data"-parameter in the definition of the User key.
- // If the user has omitted the "Data" parameter in the key definition,
- // pData points to a zero length string
- //
- // Returns:
- // < 0 : pKey1 < pKey2
- // > 0 : pKey1 > pKey2
- // 0 : pKey1 == pKey2
- //
- int WINAPI Compare(void* pKey1, unsigned KeyLen1, void* pKey2, unsigned KeyLen2, const char* pData)
- {
- int res;
-
- res = memcmp(pKey1, pKey2, KeyLen1 > KeyLen2 ? KeyLen2 : KeyLen1);
- if (res)
- // If the keys are not equal, we're finished
- return res;
- else
- // The smaller key wins!
- return KeyLen1 - KeyLen2;
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- //
- BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) {
-
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
- // a process has attached: place all required initializations here
- break;
-
- case DLL_THREAD_ATTACH:
- // a thread has attached: place all required initializations here
- break;
-
- case DLL_THREAD_DETACH:
- // a thread has detached
- break;
-
- case DLL_PROCESS_DETACH:
- // a process has detached
- break;
- }
-
- return(TRUE);
- }
-